import { baseUrl } from "./request.js"

export function topList() {
	return new Promise(function(resolve,reject){
		uni.request({
			url:`${baseUrl}/toplist/detail`,
			method:'GET',
			data:{},
			success: res => {
				let result = res.data.list
				result.length = 4;
				resolve(result)
			},
			fail: err => {
				console.log(err)
			},
			complete: () => {
				
			}
		})
	})
	
}

export function list(listid) {
	return uni.request({
		url:`${baseUrl}/playlist/detail?id=${listid}`,
		method:'GET'
	})
}

// song/detail?ids=1920280202

export function songDetail(songId) {
	return uni.request({
		url:`${baseUrl}/song/detail?ids=${songId}`,
		method:'GET'
	})
}

// simi/song?id=1920280202

export function simiSong(songId) {
	return uni.request({
		url:`${baseUrl}/simi/song?id=${songId}`,
		method:'GET'
	})
}

// comment/music?id=1920280202

export function comment(songId) {
	return uni.request({
		url:`${baseUrl}/comment/music?id=${songId}`,
		method:'GET'
	})
}

// lyric?id=1920280202

export function lyric(songId) {
	return uni.request({
		url:`${baseUrl}/lyric?id=${songId}`,
		method:'GET'
	})
}

// song/url?id=1920280202
export function songUrl(songId) {
	return uni.request({
		url:`${baseUrl}/song/url?id=${songId}`,
		method:'GET'
	})
}

// search/hot/detail
export function searchHot() {
	return uni.request({
		url:`${baseUrl}/search/hot/detail`,
		method:'GET'
	})
}

// search?keywords=海阔天空
export function searchKey(keyword) {
	return uni.request({
		url:`${baseUrl}/search?keywords=${keyword}`,
		method:'GET'
	})
}

// search/suggest?keywords=海阔天空
export function searchSuggest(keyword) {
	return uni.request({
		url:`${baseUrl}/search/suggest?keywords=${keyword}&type=mobile`,
		method:'GET'
	})
}